


<div class="layuimini-main">

    <div class="layui-form layuimini-form" lay-filter="updateForm">
        <div class="layui-form-item">
            <input type="hidden" name="id">
            <label class="layui-form-label required">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" lay-reqtext="名称不能为空" placeholder="请输入用户名" value="" class="layui-input">

            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table','axios','miniAdmin'], function () {
        let form = layui.form,
            layer = layui.layer,
            table = layui.table,
            axios = layui.axios,
            miniAdmin= layui.miniAdmin,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 当前弹出层，防止ID被覆盖
        let parentIndex = layer.index;
        //监听提交

        form.on('submit(saveBtn)', function (data) {


            axios.post('grade/update',data.field).then(function (response){
                if(response.code==200){
                    layer.msg(response.msg);
                    layui.table.reload('currentTableId')
                }
                layer.close(parentIndex);
            }).catch(function (error){
                layer.msg(error);
            });


            return false;
        });

    });
</script>